﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RuEn
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
    public class RequiredStringRule : RequiredRuleBase
    {
        private string _errorMessage = "Data Required for the Field";
        public RequiredStringRule()
        {
        }
        public RequiredStringRule(string ErrorMessage)
        {
            _errorMessage = ErrorMessage;
        }

        public string ErrorMessage
        {
            get { return _errorMessage; }
            set { _errorMessage = value; }
        }

        public bool Validate(string value, string ErrorMessage)
        {
            if (string.IsNullOrEmpty(value))
            {
                BrokenRules.Add(ErrorMessage);
                return false;
            }
            return true;
        }
    }
}
